// @ts-nocheck
import { createStore } from 'vuex'
import Index from "@/views/index/Index.vue";

export default createStore({
  state: {
    // 全局APP对象
    app: null,
    // 侧边导航栏
    isCollapse: false,
    // 头部标签栏
    headerTags: [{path: '/ywu/index', component: Index, name: 'ywu-home', meta: { title: '首页', icon: 'dashboard', affix: true }}],
    // 菜单管理
    centerDialogVisible: false, // 添加、修改菜单的弹出框
    icons: [],  // 所有菜单图标
    parentMenus: [], // 父菜单下拉框
    parentMenusCopy: [],  // 父菜单下拉框 - 备份
    menuDataList: [],  // 菜单table层级展示数据
    deleteDialogVisible: false,  // 删除菜单弹出框
    menuRoleAuthorisationDialogVisible: false, // 菜单授权弹出框
    // 菜单路由文根
    routeRootPathDataList: [], // 菜单路由文根列表
    routeRootPathSearchData: {}, // 菜单路由文根搜索条件
    routeRootPathAddOrUpdateDialogVisible: false, // 添加、修改菜单路由文根弹出框
    routeRootPathDeleteDialogVisible: false, // 删除路由文根弹出框
    // api路由&权限管理
    routerDataList: [], // 路由列表展示
    apiAddOrUpdateDialogVisible: false, // 添加、修改api的弹出框
    deleteApiDialogVisible: false,  // 删除api弹出框
    apiSearchData: {}, // api搜索条件
    apiRoleAuthorisationDialogVisible: false, // API授权弹出框
    // api缓存
    apiCacheDataList: [], // api缓存列表展示
    apiCacheSearchData: {}, // api缓存搜索条件
    // 微服务注册
    serviceApplicationDataList: [], // 微服务列表展示
    serviceApplicationSearchData: {}, // 微服务查询条件
    serviceAddOrUpdateDialogVisible: false, // 添加、修改微服务信息的弹出框
    deleteServiceDialogVisible: false, // 删除微服务弹出框
    // 微服务实例详情
    serviceInstanceApplicationDataList: [], // 微服务实例详情列表展示
    serviceInstanceApplicationSearchData: {}, // 微服务实例详情搜索条件
    // 配置中心
    configCenterSearchData: {}, // 搜索条件
    configCenterDataList: {}, // 配置中心列表数据
    configCenterAddOrUpdateDialogVisible: false, // 配置中心添加或修改配置弹出框
    configCenterDeleteDialogVisible: false, // 配置中心删除弹出框
    configCenterRefreshDialogVisible: false, // 配置中心刷新配置弹出框
    // 微服务容器管理
    serviceContainerDataList: [], // 微服务容器数据展示
    serviceContainerSearchData: {}, // 微服务容器搜索条件
    serviceContainerAddOrUpdateDialogVisible: false, // 服务部署添加或修改弹出框
    serviceContainerDeleteDialogVisible: false, // 服务部署删除弹出框
    serviceContainerDeployDialogVisible: false, // 服务部署一键部署弹出框
    // 容器实例详情
    containerInstanceDetailSearchData: {}, // 容器实例详情搜索条件
    containerInstanceDetailDataList: [], // 容器实例详情列表
    // 用户管理
    userSearchData: {}, // 用户搜索条件
    userAddOrUpdateDialogVisible: false, // 用户添加或修改弹出框
    userDeleteDialogVisible: false, // 用户删除弹出框
    userDataList: [], // 用户列表展示
    userRoleAuthorisationDialogVisible: false, // 用户角色授权弹出框
    // 角色管理
    roleSearchData: {}, // 用户搜索条件
    roleAddOrUpdateDialogVisible: false, // 角色添加或修改弹出框
    roleDeleteDialogVisible: false, // 角色删除弹出框
    roleDataList: [], // 角色列表展示
    // 租户管理
    tenantSearchData: {}, // 租户搜索条件
    tenantAddOrUpdateDialogVisible: false, // 角色添加或修改弹出框
    tenantDeleteDialogVisible: false, // 角色删除弹出框
    tenantDataList: [], // 角色列表展示
    // 租户授权管理
    tenantAuthSearchData: {}, // 租户搜索条件
    tenantAuthAddDialogVisible: false, // 租户授权添加弹出框
    tenantAuthDeleteDialogVisible: false, // 租户授权删除弹出框
    tenantAuthDataList: [], // 租户授权列表展示
    // 组件管理
    componentSearchData: {}, // 组件搜索条件
    componentUpdateDialogVisible: false, // 组件修改弹出框
    componentDeleteDialogVisible: false, // 组件删除弹出框
    componentDataList: [], // 组件列表
    // 低码组件
    lowCodeDrawerJsonInfo: {}, // 低码抽屉所展示或修改的json信息
    isShowDrawer: false, // 低码抽屉是否展示
    lowCodeComponentList: {},
    currentDrawer: "",
    currentDrawerElementId: "",
    currentDrawerTitle: "",
    userInfo: {} // 用户信息
  },
  getters: {
  },
  mutations: {
    changeApp(state, app) {
      state.app = app;
    },
    changeCollapse(state) {
      state.isCollapse = !state.isCollapse;
    },
    openCenterDialogVisible(state) {
      state.centerDialogVisible = true;
    },
    changeIcons(state, icons) {
      state.icons = icons;
    },
    changeMenuDataList(state, menuDataList) {
      state.menuDataList = menuDataList;
    },
    changeParentMenuOrCopy(state, info) {
      state.parentMenus = info;
      state.parentMenusCopy = info;
    },
    closeCenterDialogVisible(state) {
      state.centerDialogVisible = false;
    },
    openDeleteDialogVisible(state) {
      state.deleteDialogVisible = true;
    },
    closeDeleteDialogVisible(state) {
      state.deleteDialogVisible = false;
    },
    addHeaderRouteTags(state, routeInfo) {
      // 遍历判断当前tags中是否存在path，如果存在则不做操作
      let listLen = state.headerTags.length
      for (let i = 0; i < listLen; i++) {
        if (state.headerTags[i].path === routeInfo.path) {
          return;
        }
      }
      state.headerTags.push(routeInfo)
    },
    deleteHeaderRouteTags(state, routeInfo) {
      // 遍历比较path是否相同，相同则删除
      let listLen = state.headerTags.length
      for (let i = 0; i < listLen; i++) {
        if (state.headerTags[i].path === routeInfo.path) {
          state.headerTags.splice(i, 1);
          routeInfo.currentIndex = i
          return;
        }
      }
    },
    changeRouterDataList(state, routeDataList) {
      state.routerDataList = routeDataList;
    },
    openApiAddOrUpdateDialogVisible(state) {
      state.apiAddOrUpdateDialogVisible = true;
    },
    closeApiAddOrUpdateDialogVisible(state) {
      state.apiAddOrUpdateDialogVisible = false;
    },
    changeApiSearchData(state, apiSearchData) {
      state.apiSearchData = apiSearchData
    },
    openDeleteApiDialogVisible(state) {
      state.deleteApiDialogVisible = true;
    },
    changeApiRoleAuthorisationDialogVisible(state, apiRoleAuthorisationDialogVisible) {
      state.apiRoleAuthorisationDialogVisible = apiRoleAuthorisationDialogVisible;
    },
    closeDeleteApiDialogVisible(state) {
      state.deleteApiDialogVisible = false;
    },
    changeApiCacheDataList(state, apiCacheDataList) {
      state.apiCacheDataList = apiCacheDataList;
    },
    changeServiceApplicationSearchData(state, serviceApplicationSearchData) {
      state.serviceApplicationSearchData = serviceApplicationSearchData;
    },
    changeServiceApplicationDataList(state, serviceApplicationDataList) {
      state.serviceApplicationDataList = serviceApplicationDataList
    },
    changeServiceAddOrUpdateDialogVisible(state, serviceAddOrUpdateDialogVisible) {
      state.serviceAddOrUpdateDialogVisible = serviceAddOrUpdateDialogVisible;
    },
    changeDeleteServiceDialogVisible(state, deleteServiceDialogVisible) {
      state.deleteServiceDialogVisible = deleteServiceDialogVisible;
    },
    changeServiceInstanceApplicationDataList(state, serviceInstanceApplicationDataList) {
      state.serviceInstanceApplicationDataList = serviceInstanceApplicationDataList;
    },
    changeServiceInstanceApplicationSearchData(state, serviceInstanceApplicationSearchData) {
      state.serviceInstanceApplicationSearchData = serviceInstanceApplicationSearchData;
    },
    changeConfigCenterSearchData(state, configCenterSearchData) {
      state.configCenterSearchData = configCenterSearchData;
    },
    changeConfigCenterDataList(state, configCenterDataList) {
      state.configCenterDataList = configCenterDataList;
    },
    changeConfigCenterAddOrUpdateDialogVisible(state, configCenterAddOrUpdateDialogVisible) {
      state.configCenterAddOrUpdateDialogVisible = configCenterAddOrUpdateDialogVisible
    },
    changeConfigCenterDeleteDialogVisible(state, configCenterDeleteDialogVisible) {
      state.configCenterDeleteDialogVisible = configCenterDeleteDialogVisible
    },
    changeConfigCenterRefreshDialogVisible(state, configCenterRefreshDialogVisible) {
      state.configCenterRefreshDialogVisible = configCenterRefreshDialogVisible;
    },
    changeServiceContainerDataList(state, serviceContainerDataList) {
      state.serviceContainerDataList = serviceContainerDataList;
    },
    changeServiceContainerSearchData(state, serviceContainerSearchData) {
      state.serviceContainerSearchData = serviceContainerSearchData;
    },
    changeServiceContainerAddOrUpdateDialogVisible(state, serviceContainerAddOrUpdateDialogVisible) {
      state.serviceContainerAddOrUpdateDialogVisible = serviceContainerAddOrUpdateDialogVisible;
    },
    changeServiceContainerDeleteDialogVisible(state, serviceContainerDeleteDialogVisible) {
      state.serviceContainerDeleteDialogVisible = serviceContainerDeleteDialogVisible;
    },
    changeServiceContainerDeployDialogVisible(state, serviceContainerDeployDialogVisible) {
      state.serviceContainerDeployDialogVisible = serviceContainerDeployDialogVisible;
    },
    changeUserSearchData(state, userSearchData) {
      state.userSearchData = userSearchData;
    },
    changeUserAddOrUpdateDialogVisible(state, userAddOrUpdateDialogVisible) {
      state.userAddOrUpdateDialogVisible = userAddOrUpdateDialogVisible;
    },
    changeUserDeleteDialogVisible(state, userDeleteDialogVisible) {
      state.userDeleteDialogVisible = userDeleteDialogVisible;
    },
    changeUserRoleAuthorisationDialogVisible(state, userRoleAuthorisationDialogVisible) {
      state.userRoleAuthorisationDialogVisible = userRoleAuthorisationDialogVisible
    },
    changeUserDataList(state, userDataList) {
      state.userDataList = userDataList;
    },
    changeRoleSearchData(state, roleSearchData) {
      state.roleSearchData = roleSearchData;
    },
    changeRoleAddOrUpdateDialogVisible(state, roleAddOrUpdateDialogVisible) {
      state.roleAddOrUpdateDialogVisible = roleAddOrUpdateDialogVisible;
    },
    changeRoleDeleteDialogVisible(state, roleDeleteDialogVisible) {
      state.roleDeleteDialogVisible = roleDeleteDialogVisible;
    },
    changeRoleDataList(state, roleDataList) {
      state.roleDataList = roleDataList;
    },
    changeLowCodeDrawerJsonInfo(state, lowCodeDrawerJsonInfo) {
      state.lowCodeDrawerJsonInfo = lowCodeDrawerJsonInfo;
    }
  },
  actions: {
  },
  modules: {
  }
})
